package huaxin.service.impl;


import huaxin.dao.OrderDao;
import huaxin.domain.Order;
import huaxin.service.AccountService;
import huaxin.service.OrderService;
import huaxin.service.StorageService;
import io.seata.core.context.RootContext;
import io.seata.spring.annotation.GlobalTransactional;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * created by king on 2020/6/3 10:56 下午
 *
 * @author x3626
 */
@Slf4j
@Service
public class OrderServiceImpl implements OrderService {

    @Resource
    private OrderDao orderDao;

    /**
     * 创建订单->调用库存服务扣减库存->调用账户服务扣减账户余额->修改订单状态
     * 简单说：下订单->扣库存->减余额->改状态
     */
    @Override
    public void create(Order order) {
        log.info("----->开始新建订单");
        // 新建订单
        orderDao.create(order);
    }

    /**
     * 创建订单->调用库存服务扣减库存->调用账户服务扣减账户余额->修改订单状态
     * 简单说：下订单->扣库存->减余额->改状态
     */
    @Override
    public void update(Long userId, Integer status) {
        //修改订单状态，从零到1,1代表已经完成
        log.info("----->修改订单状态开始");
        orderDao.update(userId, status);
        log.info("----->修改订单状态结束");
    }
}
